﻿using CommunityToolkit.Mvvm.ComponentModel;
using SampleWpf.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleWpf.ViewModels
{
    public partial class SampleValitorViewModel :ObservableValidator
    {
        [ObservableProperty]
        [NotifyDataErrorInfo]
        [Required(ErrorMessage = "Name不能为空")]
        [MinLength(2,ErrorMessage ="最小长度不得小于2位")]
        //作用在字符串上
        private string name;

        [ObservableProperty]
        [NotifyDataErrorInfo]
        [Range(0, 160)]
        private int age;

        [ObservableProperty]
        [NotifyDataErrorInfo]
        [Required]
        private DateTime? birthDay;

        [ObservableProperty]
        [NotifyDataErrorInfo]
        //[Email]
        [RegularExpression(@"^[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$")]
        private string? email;
    }
   
}
